//
//  RootViewController.m
//  早分享WNProgressView
//
//  Created by dllo on 15/12/13.
//  Copyright © 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"
#import "WNProgressView.h"

@interface RootViewController ()

@property (nonatomic, retain) WNProgressView *proView;
@property (nonatomic, retain) NSTimer *timer;
@property (nonatomic, assign) double proValue;

@end

@implementation RootViewController

- (void)dealloc
{
    [_proView release];
    [_timer release];
    [super dealloc];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.proView = [[WNProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
    
//    设置已走过进度的进度条颜色
    
//    self.proView.progressTintColor = [UIColor blueColor];
    
//    设置未走过进度的进度条颜色
    
//    self.proView.trackTintColor = [UIColor redColor];
    
//    设置进度条进度和是否动画显示(动画显示会平滑过渡)
    
//    [self.proView setProgress:0.5 animated:YES];
    
    self.proView.frame = CGRectMake(50, 400, 300, 30);
    [self.view addSubview:self.proView];
    [_proView release];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(50, 50, 50, 50);
    button.backgroundColor = [UIColor blackColor];
    [button addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
    
    
}

- (void)changeProgress
{
    self.proValue += 1.0;
    if (self.proValue > 5) {
        [self.timer invalidate];
    } else {
        [self.proView setProgress:self.proValue / 5];
    }
}

- (void)buttonAction
{
    self.proValue = 0;
    
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(changeProgress) userInfo:nil repeats:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
